{% extends "page_templates/banner_base.html" %}
{% load facebook_tags %}
{% block schedule_block %}
	{% if logged_in_user %}
		<div class="schedule_form">
			<form action="." method="POST">
			{% csrf_token %}
				<table>
					{{ form.as_table }}
				</table>
				<p><input type="submit" value="Schedule"></p>
			</form>
		</div>
			{% if post_success %}
				<h5 id="confirmation">Game Scheduled!</h5>	
			{% endif %}
			{% if form_error %}
				<h5>Form filled out improperly. Try again.</h5>
			{% endif %}
		</br>
		{% if scheduled_games %}
			<h3>Your Scheduled Games</h3>
			<table class="scheduled_games"><tr><th>Label</th><th>Game</th><th>Date</th><th>Time</th><th>City</th><th>State</th><th>Zip</th><th>Recurring Details</th><th>Intensity</th><th>            </th></tr>
				{% for game in scheduled_games %}		
				<tr>
					<td>{{ game.label }}</td>
					<td>{{ game.game.name }}</td>
					<td>{{ game.date }}</td>
					<td>{{ game.time }}</td>
					<td>{{ game.city }}</td>
					<td>{{ game.state }}</td>
					<td>{{ game.zipcode }}</td>
					<td>{{ game.recurring_details }}</td>
					<td>{{ game.intensity }}</td>
					<td>
						<form action="." method="GET">
							<input type="hidden" name="d" value="{{ game.unique }}">
							<input type="submit" value="Cancel">
						</form>
					</td>
				</tr>
				{% endfor %}
			</table>
		{% else %}
			<h3>You have no scheduled games this time.<h3>
		{% endif %}
	{% else %}
	<h4>Welcome to the scheduling page!</h4>
		<p>Scheduling a game requires a login via Facebook. Feel free to login and schedule your own game or peruse the games created by us and our users</p>
	
	{% endif %}
	<script type="text/javascript">
		$('#schedule_button').click(function() {
			$('#confirmation').hide()
			$('#schedule_form').show('fast')
		});
	</script>

{% endblock %}
	
